<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-3-19
 * Time: 下午5:38
 */

namespace api\behaviors;


use yii\base\ActionFilter;
use yii\base\ErrorException;

class FuiouIpFilter extends ActionFilter
{
    public function beforeAction($action)
    {
        if (YII_ENV != 'dev'){
            $allow_ips = ['211.144.211.166', '211.147.90.100'];
            if (!in_array(\Yii::$app->request->userIP, $allow_ips)){
                throw new ErrorException('ip不能使用!你的IP:'.\Yii::$app->request->userIP);
            }
        }
        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }
}